package com.haizhi.crm.api.aop;


import com.alibaba.fastjson.JSON;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class ReqAop {

    @Before("execution(public * com.haizhi.crm.api.controller.*.*(..))")
    public void in(JoinPoint joinPoint) {
        Object[] objs = joinPoint.getArgs();
        if (objs != null && objs.length > 0) {
            System.out.println("入参：" + JSON.toJSONString(joinPoint.getArgs()));
        } else {
            System.out.println("入参：null");
        }
    }

    @AfterReturning(returning = "rtl", pointcut = "execution(public * com.haizhi.crm.api.controller.*.*(..))")
    public void out(Object rtl) {
        if (rtl == null) {
            System.out.println("出参：null");
        } else {
            System.out.println("出参：" + JSON.toJSONString(rtl));
        }
    }

}
